package com.xjc.market.sys.service;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xjc.infra.entity.SessionContext;
import com.xjc.infra.util.PageFrom;
import com.xjc.market.sys.biz.SysDictBiz;
import com.xjc.market.sys.entity.table.SysDict;

/**
 * 数据字典service
 * @author liangcz
 * @Date   2017年9月15日 下午4:43:21
 * @version 1.0
 */
@RestController
@Controller
@RequestMapping("/sys/service/SysDictService")
public class SysDictService {
	@Autowired
	SysDictBiz sysDictBiz;
	/**
	 * 获取数据字典
	 * @author liangcz
	 * @date   2017年9月15日 下午4:45:14
	 * @return void
	 */
	@RequestMapping("/getDict")
	public void getDict(SessionContext sessionContext,HttpServletRequest request, HttpServletResponse response,SysDict sysDict){
		List<SysDict> inquirylists = sysDictBiz.selectList(sysDict);
		List<SysDict> returnList = new ArrayList<>();
		if(inquirylists != null && inquirylists.size() != 0){
			/* 加一个空值返回，前端下拉显示多一个空选项 */
			SysDict sysDict1 = new SysDict();
			sysDict1.setDictItemCode("");
			returnList.add(sysDict1);
			returnList.addAll(inquirylists);
		}
		PageFrom.jsonResponseWriter(returnList, response);
	}
}
